package com.mediacloud.app.newsmodule.fragment.video.vod

import android.content.Context
import android.graphics.Color
import android.widget.FrameLayout
import android.widget.SeekBar
import androidx.lifecycle.LifecycleOwner
import com.mediacloud.app.view.XViewPager
import com.yoake.media.player.XPlayer

class XListPlayer(context: Context,owner: LifecycleOwner) : FrameLayout(context), SeekBar.OnSeekBarChangeListener {
    val p = XPlayer(context,owner)
    var viewPlayer: XViewPager? = null

    init {
        val c = Color.parseColor("#1d1b28")
        setBackgroundColor(c)
        p.gestureView.interceptWhenNormalOpenTwiceSpeed = true
        p.playWithMute = true
        // p.debug = true
        p.getPlayerContainer().setBackgroundColor(c)
        p.prepareView.playBtn.visibility = GONE
        p.onResumePlay = false
        p.autoPlay = true
        p.normalStateDisableGesture = true
        p.hideTitleLayoutWhenInNormalState()
        addView(p, -1, -1)
        p.bottomControl.iBottomControlView?.setSeekBarChangeListener(this)
    }

    override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {

    }

    override fun onStartTrackingTouch(seekBar: SeekBar?) {
        viewPlayer?.noScroll = true
    }

    override fun onStopTrackingTouch(seekBar: SeekBar?) {
        viewPlayer?.noScroll = false
    }
}